package com.txts.road.admin.vehicleSys.controller;

import com.txts.base.common.domain.PageResult;
import com.txts.base.common.domain.ResponseDTO;
import com.txts.road.admin.common.annotation.Anonymous;
import com.txts.road.admin.common.annotation.Log;
import com.txts.road.admin.common.core.controller.BaseController;
import com.txts.road.admin.common.core.domain.AjaxResult;
import com.txts.road.admin.common.core.page.TableDataInfo;
import com.txts.road.admin.common.enums.BusinessType;
import com.txts.road.admin.common.utils.poi.ExcelUtil;
import com.txts.road.admin.vehicleSys.domain.raceVehicle;
import com.txts.road.admin.vehicleSys.service.IraceVehicleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletResponse;

import java.util.List;

/**
 * 参赛车辆Controller
 *
 * @author ruoyi
 * @date 2025-05-15
 */
@RestController
@RequestMapping("/vehicleSys/raceVihicle")
@Tag(name = "参事车辆接口")
public class raceVehicleController extends BaseController {
    @Resource
    private IraceVehicleService raceVehicleService;

    /**
     * 查询参赛车辆列表
     */
    @Anonymous
    @GetMapping("/list")
    @Operation(summary = "查询参赛车辆列表", description = "根据条件查询参赛车辆列表")
    public ResponseDTO<PageResult<raceVehicle>> list(raceVehicle raceVehicle) {
        startPage();
        List<raceVehicle> list = raceVehicleService.selectraceVehicleList(raceVehicle);
        return getDataTable(list);
    }

    /**
     * 导出参赛车辆列表
     */
    @PreAuthorize("@ss.hasPermi('vehicleSys:raceVihicle:export')")
    @Log(title = "参赛车辆", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出参赛车辆列表", description = "导出参赛车辆列表")
    public void export(HttpServletResponse response, raceVehicle raceVehicle) {
        List<raceVehicle> list = raceVehicleService.selectraceVehicleList(raceVehicle);
        ExcelUtil<raceVehicle> util = new ExcelUtil<raceVehicle>(raceVehicle.class);
        util.exportExcel(response, list, "参赛车辆数据");
    }

    /**
     * 获取参赛车辆详细信息
     */
    @PreAuthorize("@ss.hasPermi('vehicleSys:raceVihicle:query')")
    @GetMapping(value = "/{id}")
    @Operation(summary = "获取参赛车辆详细信息", description = "根据ID获取参赛车辆详细信息")
    public ResponseDTO<Object> getInfo(@PathVariable("id") Long id) {
        return success(raceVehicleService.selectraceVehicleById(id));
    }

    /**
     * 新增参赛车辆
     */
    @PreAuthorize("@ss.hasPermi('vehicleSys:raceVihicle:add')")
    @Log(title = "参赛车辆", businessType = BusinessType.INSERT)
    @PostMapping
    @Operation(summary = "新增参赛车辆", description = "新增参赛车辆")
    public ResponseDTO<Object> add(@RequestBody raceVehicle raceVehicle) {
        return toAjax(raceVehicleService.insertraceVehicle(raceVehicle));
    }

    /**
     * 修改参赛车辆
     */
    @PreAuthorize("@ss.hasPermi('vehicleSys:raceVihicle:edit')")
    @Log(title = "参赛车辆", businessType = BusinessType.UPDATE)
    @PutMapping
    @Operation(summary = "修改参赛车辆", description = "修改参赛车辆")
    public ResponseDTO<Object> edit(@RequestBody raceVehicle raceVehicle) {
        return toAjax(raceVehicleService.updateraceVehicle(raceVehicle));
    }

    /**
     * 删除参赛车辆
     */
    @PreAuthorize("@ss.hasPermi('vehicleSys:raceVihicle:remove')")
    @Log(title = "参赛车辆", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除参赛车辆", description = "删除参赛车辆")
    public ResponseDTO<Object> remove(@PathVariable Long[] ids) {
        return toAjax(raceVehicleService.deleteraceVehicleByIds(ids));
    }
}
